package com.ruoyi.system.controller;

import com.ruoyi.system.DTO.Reques.partner.PartnerSearchDTO;
import com.ruoyi.system.pojo.partner.Partner;
import com.ruoyi.system.service.PartnerService;
import com.ruoyi.system.utils.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user-service/partner")
public class PartnerController {

    @Autowired
    private PartnerService partnerService;

    @GetMapping("/search")
    public ResponseEntity<PageResult<Partner>> searchPartners(
            @RequestParam(required = false) Integer pageIndex,
            @RequestParam(required = false) Integer pageSize,
            @RequestParam(required = false) String name) {

        PartnerSearchDTO searchDTO = new PartnerSearchDTO();
        searchDTO.setPageIndex(pageIndex);
        searchDTO.setPageSize(pageSize);
        searchDTO.setName(name);

        PageResult<Partner> result = partnerService.searchPartners(searchDTO);
        return ResponseEntity.ok(result);
    }

}
